package com.itxiao.controller;

import com.itxiao.annotation.Token;
import com.itxiao.config.SystemConfig;
import com.itxiao.entity.User;
import com.itxiao.pojo.dto.AddCollectDto;
import com.itxiao.pojo.dto.UpdateUserDto;
import com.itxiao.pojo.vo.R;
import com.itxiao.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.Serializable;
import java.util.List;

/**
 * (User)表控制层
 *
 * @author makejava
 * @since 2025-10-12 17:16:47
 */
@RestController
@RequestMapping("admin/api/v1/user")
@Api(tags = "用户模块")
@CrossOrigin
public class UserController extends BaseController<UserService, User> {
   @Resource
   UserService userService;
    @ApiOperation("查询用户个人信息")
    @GetMapping("/query-detail")
    @Token
    public R queryDetail(HttpServletRequest request) {
        return userService.queryDetail(request.getHeader(SystemConfig.HEADER_TOKEN));
    }

    @ApiOperation("修改个人用户信息")
    @PutMapping("/update")
    @Token
    public R updateInfo(@RequestBody UpdateUserDto dto, HttpServletRequest request) {
        return userService.updateInfo( dto,request.getHeader(SystemConfig.HEADER_TOKEN));
    }
    @PostMapping("/api/oss/uploadimg")
    public R uploadImg(@RequestPart MultipartFile file) throws IOException {
        return userService.uploadImg(file);
    }
}

